package com.yn.front.zy;


import com.yn.common.model.user.User;
import com.yn.common.page.BasePage;
import com.yn.common.request.sc.PageParamRequest;
import com.yn.common.request.zy.ReturnPlanQuery;
import com.yn.common.response.driver.DepartureDetailResponse;
import com.yn.common.response.driver.DeparturePlanResponse;
import com.yn.common.utils.genutils.CommonResult;
import com.yn.service.service.ICarDeparturePlanService;
import com.yn.service.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 司机返程计划表 前端控制器
 * </p>
 *
 * @author xuquanjun
 * @since 2025-07-02
 */
@RestController
@RequestMapping("api/user/sfc")
@Slf4j
@Api(tags = "查看顺风车行程——wx用户端")

public class HitchhikingController {
    @Resource
    private ICarDeparturePlanService carDeparturePlanService;

    @Resource
    private UserService userService;


    /**
     * 司机查看自己发单列表
     * @param query 查询参数
     * @param pageRequest 分页参数
     * @return BaseResult<BasePage<DeparturePlanResponse>>
     */
    @ApiOperation(value = "返程计划列表")
    @GetMapping(value = "/departure/list")
    public CommonResult<BasePage<DeparturePlanResponse>> orderList(ReturnPlanQuery query, PageParamRequest pageRequest) {
        User user = userService.getInfoException();
        BasePage<DeparturePlanResponse> response= carDeparturePlanService.orderList(query,pageRequest,user);
        return CommonResult.success(response);
    }

    /**
     * 查看返车计划详情
     * @param id 返车计划id
     * @return OrderDetailResponse
     */
    @ApiOperation(value = "查询订单详情")
    @GetMapping(value = "/departure/detail")
    public CommonResult<DepartureDetailResponse> OrderDetail(@RequestParam @NotNull Integer id) {
        User user = userService.getInfoException();
        DepartureDetailResponse response= carDeparturePlanService.OrderDetail(id,user);
        return CommonResult.success(response);
    }

}
